package com.zhoukx.iterator;

import java.util.Iterator;

/**
 * @ClassName ComputerCollegeIterator
 * @Description:
 * @Author zhoukx
 * @Date 2020/8/17
 **/
public class ComputerCollegeIterator  implements Iterator {
    // 这里我们需要department 是以怎么样的方式存放的
    Department[] departments;
    // 遍历的位置
    int position = 0;

    public ComputerCollegeIterator(Department[] departments) {
        this.departments = departments;
    }

    @Override
    public boolean hasNext() {
        // 判断是否有下一个元素
        if (position >= departments.length || departments[position] == null) {
            return  false;
        }else {
            return true;
        }

    }

    @Override
    public Object next() {
        Department department = departments[position];
        position += 1;
        return department;
    }

    //  删除的方法空实现
    @Override
    public void remove() {

    }
}
